home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / boot / snap_v2_0.lha / Snap / OpenClose.c < prev    next >
C/C++ Source or Header  |  1995-09-04  |  14KB  |  640 lines

  1. /* Auto: make "CCEXTRA=-wq -qf"
  2.  */
  3.  
  4. #include "Snap.h"
  5.  
  6. IMPORT BOOL Kick36;
  7.  
  8. IMPORT LONGBITS startsignal, insertsignal, cancelsignal;
  9. IMPORT LONGBITS donesignal, movesignal, clicksignal;
  10. IMPORT LONGBITS timersignal, initsignal, cwsignal, ticksignal;
  11. IMPORT ULONG startsignum, insertsignum, cancelsignum;
  12. IMPORT ULONG donesignum, movesignum, clicksignum;
  13. IMPORT ULONG initsignum, cwsignum, ticksignum;
  14.  
  15. /* program */
  16. IMPORT struct SnapRsrc *SnapRsrc;
  17. IMPORT struct Task *MyTask;
  18.  
  19. /* Snap state machine */
  20. IMPORT WORD action;
  21. IMPORT WORD state;
  22.  
  23. /* clipboard */
  24. IMPORT struct IOClipReq *ClipReq;
  25. IMPORT struct MsgPort *ClipPort;
  26.  
  27. /* timer device */
  28. IMPORT struct MsgPort *TimerPort;
  29. IMPORT struct timerequest MyTR;
  30.  
  31. /* input device */
  32. IMPORT struct MsgPort *inputDevPort;
  33. IMPORT struct Interrupt handlerStuff;
  34. IMPORT struct IOStdReq *inputRequestBlock;
  35.  
  36. IMPORT UBYTE *CharData;
  37.  
  38. /* console */
  39. IMPORT struct MsgPort *ConPort;
  40. IMPORT struct IOStdReq *ConIOR;
  41. IMPORT struct KeyMap keymap;
  42.  
  43. /* windows */
  44. #ifdef SNAPGFX
  45. IMPORT struct MsgPort *Sharedport;
  46. IMPORT SHORT Sharedrefs;
  47.  
  48. #endif    /* SNAPGFX */
  49.  
  50. /* libraries */
  51. IMPORT struct IntuitionBase *IntuitionBase;
  52. IMPORT struct GfxBase *GfxBase;
  53. IMPORT struct Library *LayersBase;
  54. IMPORT struct Library *DiskfontBase;
  55. IMPORT struct Library *IconBase;
  56.  
  57. #ifdef SNAPGFX
  58. #ifdef REQLIB
  59. IMPORT struct ReqBase *ReqBase;
  60.  
  61. #endif    /* REQLIB */
  62. #ifdef ASLLIB
  63. IMPORT struct Library *AslBase;
  64.  
  65. #endif    /* ASLLIB */
  66. #endif    /* SNAPGFX */
  67.  
  68. /* graphics */
  69. IMPORT struct RastPort TempRp;
  70. IMPORT struct BitMap TempBM;
  71. IMPORT UBYTE *TempRaster;
  72.  
  73. #ifdef SNAPGFX
  74. #ifdef REQLIB
  75. IMPORT struct ReqFileRequester *NameFR;
  76.  
  77. #endif    /* REQLIB */
  78. #ifdef ASLLIB
  79. #define SetTag( t,i,v) { ( t).ti_Tag = i; ( t).ti_Data = ( ULONG)( v); }
  80. IMPORT struct FileRequester *AslNameFR;
  81.  
  82. #endif    /* ASLLIB */
  83.  
  84. IMPORT struct Image ActiveDiskImage;
  85. IMPORT struct Image InactiveDiskImage;
  86. IMPORT struct Image SelDiskImage;
  87. IMPORT struct Image ActiveClipImage;
  88. IMPORT struct Image InactiveClipImage;
  89. IMPORT struct Image SelClipImage;
  90. IMPORT struct Gadget DiskGad;
  91. IMPORT struct Gadget ClipGad;
  92.  
  93. UWORD DiskImData36[ 144] =
  94. {
  95.     /* Inactive */
  96.     0x0000, 0x0000,
  97.     0x0000, 0x4000,
  98.     0x07f8, 0x4000,
  99.     0x0408, 0x4000,
  100.     0x05E8, 0x4000,
  101.     0x0408, 0x4000,
  102.     0x07F8, 0x4000,
  103.     0x0618, 0x4000,
  104.     0x0698, 0x4000,
  105.     0x0698, 0x4000,
  106.     0x0000, 0x4000,
  107.     0x7FFF, 0xC000,
  108.  
  109.     0xFFFF, 0xC000,
  110.     0x8000, 0x0000,
  111.     0x8000, 0x0000,
  112.     0x8000, 0x0000,
  113.     0x8000, 0x0000,
  114.     0x8000, 0x0000,
  115.     0x8000, 0x0000,
  116.     0x8000, 0x0000,
  117.     0x8000, 0x0000,
  118.     0x8000, 0x0000,
  119.     0x8000, 0x0000,
  120.     0x8000, 0x0000,
  121.  
  122.     /* Active */
  123.     0x0000, 0x0000,
  124.     0x7FFF, 0xC000,
  125.     0x7FFF, 0xC000,
  126.     0x7C0F, 0xC000,
  127.     0x7DEF, 0xC000,
  128.     0x7C0F, 0xC000,
  129.     0x7FFF, 0xC000,
  130.     0x7E1F, 0xC000,
  131.     0x7E9F, 0xC000,
  132.     0x7E9F, 0xC000,
  133.     0x7FFF, 0xC000,
  134.     0x7FFF, 0xC000,
  135.  
  136.     0xFFFF, 0xC000,
  137.     0xFFFF, 0x8000,
  138.     0xF807, 0x8000,
  139.     0xFBF7, 0x8000,
  140.     0xFA17, 0x8000,
  141.     0xFBF7, 0x8000,
  142.     0xF807, 0x8000,
  143.     0xF9E7, 0x8000,
  144.     0xF967, 0x8000,
  145.     0xF967, 0x8000,
  146.     0xFFFF, 0x8000,
  147.     0x8000, 0x0000,
  148.  
  149.     /* Selected */
  150.     0xFFFF, 0xC000,
  151.     0xFFFF, 0x8000,
  152.     0xFFFF, 0x8000,
  153.     0xFC0F, 0x8000,
  154.     0xFDEF, 0x8000,
  155.     0xFC0F, 0x8000,
  156.     0xFFFF, 0x8000,
  157.     0xFE1F, 0x8000,
  158.     0xFE9F, 0x8000,
  159.     0xFE9F, 0x8000,
  160.     0xFFFF, 0x8000,
  161.     0x8000, 0x0000,
  162.  
  163.     0x0000, 0x0000,
  164.     0x7FFF, 0xC000,
  165.     0x7807, 0xC000,
  166.     0x7BF7, 0xC000,
  167.     0x7A17, 0xC000,
  168.     0x7BF7, 0xC000,
  169.     0x7807, 0xC000,
  170.     0x79E7, 0xC000,
  171.     0x7967, 0xC000,
  172.     0x7967, 0xC000,
  173.     0x7FFF, 0xC000,
  174.     0x7FFF, 0xC000
  175. };
  176.  
  177. UWORD DiskImData[ 13] =
  178. {
  179.     /* BitPlane 0 */
  180.     0xFFFF,
  181.     0xFFFF,
  182.     0xFFFF,
  183.     0xF00F,
  184.     0xF7EF,
  185.     0xF42F,
  186.     0xF7EF,
  187.     0xF00F,
  188.     0xF3CF,
  189.     0xF2CF,
  190.     0xF2CF,
  191.     0xFFFF,
  192.     0xFFFF
  193. };
  194.  
  195. UWORD ClipImData36[ 156] =
  196. {
  197.     /* Inactive */
  198.     0x0000, 0x0000,
  199.     0x0000, 0x4000,
  200.     0x0C00, 0x4000,
  201.     0x120E, 0x4000,
  202.     0x1A38, 0x4000,
  203.     0x0EE0, 0x4000,
  204.     0x0380, 0x4000,
  205.     0x0EE0, 0x4000,
  206.     0x1A38, 0x4000,
  207.     0x120E, 0x4000,
  208.     0x0C00, 0x4000,
  209.     0x0000, 0x4000,
  210.     0x7FFF, 0xC000,
  211.  
  212.     0xFFFF, 0xC000,
  213.     0x8000, 0x0000,
  214.     0x8000, 0x0000,
  215.     0x8000, 0x0000,
  216.     0x8000, 0x0000,
  217.     0x8000, 0x0000,
  218.     0x8000, 0x0000,
  219.     0x8000, 0x0000,
  220.     0x8000, 0x0000,
  221.     0x8000, 0x0000,
  222.     0x8000, 0x0000,
  223.     0x8000, 0x0000,
  224.     0x8000, 0x0000,
  225.  
  226.     /* Active */
  227.     0x0000, 0x0000,
  228.     0x7FFF, 0xC000,
  229.     0x7FFF, 0xC000,
  230.     0x7FFF, 0xC000,
  231.     0x7FFF, 0xC000,
  232.     0x7FFF, 0xC000,
  233.     0x7FFF, 0xC000,
  234.     0x7FFF, 0xC000,
  235.     0x7FFF, 0xC000,
  236.     0x7FFF, 0xC000,
  237.     0x7FFF, 0xC000,
  238.     0x7FFF, 0xC000,
  239.     0x7FFF, 0xC000,
  240.  
  241.     0xFFFF, 0xC000,
  242.     0xFFFF, 0x8000,
  243.     0xF3FF, 0x8000,
  244.     0xEDF1, 0x8000,
  245.     0xE5C7, 0x8000,
  246.     0xF11F, 0x8000,
  247.     0xFC7F, 0x8000,
  248.     0xF11F, 0x8000,
  249.     0xE5C7, 0x8000,
  250.     0xEDF1, 0x8000,
  251.     0xF3FF, 0x8000,
  252.     0xFFFF, 0x8000,
  253.     0x8000, 0x0000,
  254.  
  255.     /* Selected */
  256.     0xFFFF, 0xC000,
  257.     0xFFFF, 0x8000,
  258.     0xFFFF, 0x8000,
  259.     0xFFFF, 0x8000,
  260.     0xFFFF, 0x8000,
  261.     0xFFFF, 0x8000,
  262.     0xFFFF, 0x8000,
  263.     0xFFFF, 0x8000,
  264.     0xFFFF, 0x8000,
  265.     0xFFFF, 0x8000,
  266.     0xFFFF, 0x8000,
  267.     0xFFFF, 0x8000,
  268.     0x8000, 0x0000,
  269.  
  270.     0x0000, 0x0000,
  271.     0x7FFF, 0xC000,
  272.     0x73FF, 0xC000,
  273.     0x6DF1, 0xC000,
  274.     0x65C7, 0xC000,
  275.     0x711F, 0xC000,
  276.     0x7C7F, 0xC000,
  277.     0x711F, 0xC000,
  278.     0x65C7, 0xC000,
  279.     0x6DF1, 0xC000,
  280.     0x73FF, 0xC000,
  281.     0x7FFF, 0xC000,
  282.     0x7FFF, 0xC000
  283. };
  284.  
  285. UWORD ClipImData[ 14] =
  286. {
  287.     /* BitPlane 0 */
  288.     0xFFFF,
  289.     0xFFFF,
  290.     0xE7FF,
  291.     0xDBE3,
  292.     0xCB8F,
  293.     0xE23F,
  294.     0xF8FF,
  295.     0xE23F,
  296.     0xCB8F,
  297.     0xDBE3,
  298.     0xE7FF,
  299.     0xFFFF,
  300.     0xFFFF,
  301.     0xFFFF
  302. };
  303.  
  304. #endif    /* SNAPGFX */
  305.  
  306. VOID CloseStuff( )
  307. {
  308.     SafeRestore( );
  309.     if ( SnapRsrc)
  310.     {
  311.         KILLLIST( &SnapRsrc->CachedWindows, struct CacheWindow);
  312.  
  313.         if ( SnapRsrc->AlternateFont)
  314.         {
  315.             CloseFont( SnapRsrc->AlternateFont);
  316.         }
  317.     }
  318. #ifdef SNAPGFX
  319.     if ( InactiveDiskImage.ImageData)
  320.     {
  321.         FreeMem( InactiveDiskImage.ImageData,
  322.               Kick36 ? sizeof ( DiskImData36) : sizeof ( DiskImData));
  323.     }
  324.     if ( InactiveClipImage.ImageData)
  325.     {
  326.         FreeMem( InactiveClipImage.ImageData,
  327.               Kick36 ? sizeof ( ClipImData36) : sizeof ( ClipImData));
  328.     }
  329. #endif    /* SNAPGFX */
  330.     if ( TempRaster)
  331.         FreeRaster( TempRaster, 16L, CHEIGHT);
  332.     if ( CharData)
  333.         FreeRaster( CharData, 16L, 256L * CHEIGHT);
  334.     if ( inputRequestBlock)
  335.     {
  336.         if ( inputRequestBlock->io_Device)
  337.         {
  338.             inputRequestBlock->io_Command = IND_REMHANDLER;        /* Remove handler */
  339.             inputRequestBlock->io_Data = ( APTR) & handlerStuff;
  340.             DoIO( ( struct IORequest *)inputRequestBlock);
  341.             CloseDevice( ( struct IORequest *)inputRequestBlock);
  342.         }
  343.         DeleteExtIO( ( struct IORequest *)inputRequestBlock);
  344.     }
  345.     if ( inputDevPort)
  346.         DeletePort( inputDevPort);
  347.     if ( TimerPort)
  348.     {
  349.         DeletePort( TimerPort);
  350.         CloseDevice( ( struct IORequest *)&MyTR);
  351.     }
  352.     if ( ConIOR)
  353.     {
  354.         CloseDevice( ( struct IORequest *)ConIOR);
  355.         DeleteExtIO( ( struct IORequest *)ConIOR);
  356.     }
  357.     if ( ConPort)
  358.         DeletePort( ConPort);
  359.     if ( ClipReq)
  360.     {
  361.         if ( ClipReq->io_Device)
  362.         {
  363.             CloseDevice( ( struct IORequest *)ClipReq);
  364.         }
  365.         DeleteExtIO( ( struct IORequest *)ClipReq);
  366.     }
  367.     if ( ClipPort)
  368.         DeletePort( ClipPort);
  369.     if ( startsignum != -1)
  370.         FreeSignal( startsignum);
  371.     if ( donesignum != -1)
  372.         FreeSignal( donesignum);
  373.     if ( cancelsignum != -1)
  374.         FreeSignal( cancelsignum);
  375.     if ( movesignum != -1)
  376.         FreeSignal( movesignum);
  377.     if ( insertsignum != -1)
  378.         FreeSignal( insertsignum);
  379.     if ( clicksignum != -1)
  380.         FreeSignal( clicksignum);
  381.     if ( initsignum != -1)
  382.         FreeSignal( initsignum);
  383.     if ( cwsignum != -1)
  384.         FreeSignal( cwsignum);
  385.     if ( ticksignum != -1)
  386.         FreeSignal( ticksignum);
  387.     if ( SnapRsrc)
  388.     {
  389.         RemResource( ( struct MiscResource *)SnapRsrc);
  390.         Kill( SnapRsrc);
  391.     }
  392. #ifdef SNAPGFX
  393. #ifdef ASLLIB
  394.     if ( AslBase && AslNameFR)
  395.         FreeFileRequest( AslNameFR);
  396. #endif    /* ASLLIB */
  397. #ifdef REQLIB
  398.     if ( ReqBase && NameFR)
  399.         Delete( NameFR);
  400. #endif    /* REQLIB */
  401. #endif    /* SNAPGFX */
  402. }
  403.  
  404. VOID CloseLibs( )
  405. {
  406. #ifdef SNAPGFX
  407. #ifdef ASLLIB
  408.     if ( AslBase)
  409.         CloseLibrary( AslBase);
  410. #endif    /* ASLLIB */
  411. #ifdef REQLIB
  412.     if ( ReqBase)
  413.         CloseLibrary( ( struct Library *)ReqBase);
  414. #endif    /* REQLIB */
  415. #endif    /* SNAPGFX */
  416.     if ( IconBase)
  417.         CloseLibrary( IconBase);
  418.     if ( DiskfontBase)
  419.         CloseLibrary( ( struct Library *)DiskfontBase);
  420.     if ( IntuitionBase)
  421.         CloseLibrary( ( struct Library *)IntuitionBase);
  422.     if ( GfxBase)
  423.         CloseLibrary( ( struct Library *)GfxBase);
  424.     if ( LayersBase)
  425.         CloseLibrary( ( struct Library *)LayersBase);
  426. }
  427.  
  428. WORD OpenLibs( )
  429. {
  430.     /* libraries */
  431.  
  432.     if ( !( GfxBase = ( struct GfxBase *)OpenLibrary( "graphics.library", 0L)))
  433.         return 0;
  434.     if ( !( IntuitionBase = ( struct IntuitionBase *)OpenLibrary( "intuition.library", 0L)))
  435.         return 0;
  436.     if ( !( LayersBase = OpenLibrary( "layers.library", 0L)))
  437.         return 0;
  438.     DiskfontBase = OpenLibrary( "diskfont.library", 0L);
  439.     IconBase = OpenLibrary( ICONNAME, 0L);
  440. #ifdef SNAPGFX
  441. #ifdef REQLIB
  442.     ReqBase = ( struct ReqBase *)OpenLibrary( "req.library", 0L);
  443. #endif    /* REQLIB */
  444. #ifdef ASLLIB
  445.     AslBase = OpenLibrary( AslName, 0L);
  446. #endif    /* ASLLIB */
  447. #endif
  448.     return 1;
  449. }
  450.  
  451. WORD OpenStuff( )
  452. {
  453.     action = noaction;
  454.     state = waiting;
  455.     inputRequestBlock = NULL;
  456.  
  457. #ifdef SNAPGFX
  458.     Sharedrefs = 0;
  459.     Sharedport = NULL;
  460. #endif    /* SNAPGFX */
  461.  
  462.     /* Set up everything we need. */
  463.  
  464. #ifdef SNAPGFX
  465. #ifdef REQLIB
  466.     if ( ReqBase)
  467.     {
  468.         NameFR = Create( ReqFileRequester);
  469.     }
  470. #endif    /* REQLIB */
  471. #ifdef ASLLIB
  472.     if ( AslBase)
  473.     {
  474.         struct TagItem FRTags[ 4];
  475.  
  476.         SetTag( FRTags[ 0], ASL_Hail, "Save Picture As...");
  477.         SetTag( FRTags[ 1], ASL_Dir, "t:");
  478.         SetTag( FRTags[ 2], ASL_File, "Snap.pic");
  479.         SetTag( FRTags[ 3], TAG_END, NULL);
  480.         AslNameFR = AllocAslRequest( ASL_FileRequest, FRTags);
  481.     }
  482. #endif    /* ASLLIB */
  483. #endif    /* SNAPGFX */
  484.  
  485.     /* signals */
  486.  
  487.     if ( ( startsignum = AllocSignal( -1L)) == -1L)
  488.         return 0;
  489.     if ( ( insertsignum = AllocSignal( -1L)) == -1L)
  490.         return 0;
  491.     if ( ( cancelsignum = AllocSignal( -1L)) == -1L)
  492.         return 0;
  493.     if ( ( donesignum = AllocSignal( -1L)) == -1L)
  494.         return 0;
  495.     if ( ( movesignum = AllocSignal( -1L)) == -1L)
  496.         return 0;
  497.     if ( ( clicksignum = AllocSignal( -1L)) == -1L)
  498.         return 0;
  499.     if ( ( initsignum = AllocSignal( -1L)) == -1L)
  500.         return 0;
  501.     if ( ( cwsignum = AllocSignal( -1L)) == -1L)
  502.         return 0;
  503.     if ( ( ticksignum = AllocSignal( -1L)) == -1L)
  504.         return 0;
  505.     MyTask = FindTask( NULL);    /* Find myself to Signal me.  */
  506.     startsignal = 1L << startsignum;    /* No good to use bit numbers */
  507.     insertsignal = 1L << insertsignum;
  508.     cancelsignal = 1L << cancelsignum;
  509.     donesignal = 1L << donesignum;
  510.     movesignal = 1L << movesignum;
  511.     clicksignal = 1L << clicksignum;
  512.     initsignal = 1L << initsignum;
  513.     cwsignal = 1L << cwsignum;
  514.     ticksignal = 1L << ticksignum;
  515.  
  516.     /* clipboard device */
  517.  
  518.     if ( !( ClipPort = CreatePort( 0L, 0L)))
  519.         return 0;
  520.     if ( !( ClipReq = ( struct IOClipReq *)CreateExtIO( ClipPort, ( LONG) sizeof ( *ClipReq))))
  521.         return 0;
  522.     if ( OpenDevice( "clipboard.device", 0L, ( struct IORequest *)ClipReq, 0L))
  523.         return 0;
  524.     ClipReq->io_ClipID = 0L;
  525.  
  526.     /* console device */
  527.  
  528.     if ( !( ConPort = CreatePort( 0L, 0L)))
  529.         return 0;
  530.     if ( !( ConIOR = ( struct IOStdReq *)CreateExtIO( ConPort, ( LONG) sizeof ( struct IOStdReq))))
  531.          return 0;
  532.  
  533.     if ( OpenDevice( "console.device", -1L, ( struct IORequest *)ConIOR, 0L))
  534.         return 0;
  535.  
  536.     /* timer device */
  537.     if ( !( TimerPort = CreatePort( NULL, 0L)))
  538.         return 0;
  539.     timersignal = 1L << TimerPort->mp_SigBit;
  540.     if ( OpenDevice( TIMERNAME, UNIT_VBLANK, ( struct IORequest *)&MyTR, 0))
  541.         return 0;
  542.     MyTR.tr_node.io_Message.mn_ReplyPort = TimerPort;
  543.     MyTR.tr_node.io_Error = 0;
  544.  
  545.     /* input device */
  546.  
  547.     if ( !( inputDevPort = CreatePort( 0L, 0L)))
  548.         return 0;
  549.     if ( !( inputRequestBlock = ( struct IOStdReq *)CreateExtIO( inputDevPort, ( LONG) sizeof ( struct IOStdReq))))
  550.          return 0;
  551.  
  552.     if ( OpenDevice( "input.device", 0L, ( struct IORequest *)inputRequestBlock, 0L))
  553.         return 0;
  554.  
  555.     /* input handler */
  556.  
  557.     handlerStuff.is_Data = ( APTR) 0x534E4150;    /* Set up for installation of */
  558.     handlerStuff.is_Code = (void (* )())myhandler;    /* myhandler. */
  559.     handlerStuff.is_Node.ln_Pri = SnapRsrc->Priority;
  560.     /* Ahead of intuition, please */
  561.     handlerStuff.is_Node.ln_Name = "Snap Input Handler";
  562.  
  563.     inputRequestBlock->io_Command = IND_ADDHANDLER;
  564.     inputRequestBlock->io_Data = ( APTR) & handlerStuff;
  565.  
  566.     DoIO( ( struct IORequest *)inputRequestBlock);    /* Add me. */
  567.  
  568.  
  569.     /* Aligned font bitmap to use when matching */
  570.  
  571.     if ( !( CharData = AllocRaster( 16L, 256L * CHEIGHT)))
  572.     {
  573.         return 0;
  574.     }
  575.  
  576.     /* temporary raster */
  577.  
  578.     if ( !( TempRaster = AllocRaster( 16L, CHEIGHT)))
  579.         return 0;
  580.     InitRastPort( &TempRp);    /* Init RastPort used for */
  581.     InitBitMap( &TempBM, 1L, 16L, CHEIGHT);    /* Locating position of   */
  582.     TempBM.Planes[ 0] = TempRaster;    /* first character.       */
  583.     TempRp.BitMap = &TempBM;
  584.  
  585. #ifdef SNAPGFX
  586.     {
  587.         WORD i;
  588.         UWORD *DiskImageData;
  589.         UWORD *ClipImageData;
  590.         LONG DiskImageSize;
  591.         LONG ClipImageSize;
  592.  
  593.         if ( Kick36)
  594.         {
  595.             ActiveDiskImage = SelDiskImage = InactiveDiskImage;
  596.             ActiveClipImage = SelClipImage = InactiveClipImage;
  597.             DiskImageData = DiskImData36;
  598.             ClipImageData = ClipImData36;
  599.             DiskImageSize = sizeof ( DiskImData36);
  600.             ClipImageSize = sizeof ( ClipImData36);
  601.             DiskGad.Flags |= GADGHIMAGE;
  602.             ClipGad.Flags |= GADGHIMAGE;
  603.         }
  604.         else
  605.         {
  606.             InactiveDiskImage = SelDiskImage = ActiveDiskImage;
  607.             InactiveClipImage = SelClipImage = ActiveClipImage;
  608.             DiskImageData = DiskImData;
  609.             ClipImageData = ClipImData;
  610.             DiskImageSize = sizeof ( DiskImData);
  611.             ClipImageSize = sizeof ( ClipImData);
  612.             DiskGad.Flags |= GADGHCOMP;
  613.             ClipGad.Flags |= GADGHCOMP;
  614.         }
  615.         if ( !( InactiveDiskImage.ImageData = AllocMem( DiskImageSize, MEMF_CHIP)))
  616.         {
  617.             return 0;
  618.         }
  619.         ActiveDiskImage.ImageData = &InactiveDiskImage.ImageData[ Kick36 ? 48 : 0];
  620.         SelDiskImage.ImageData = &InactiveDiskImage.ImageData[ Kick36 ? 96 : 0];
  621.         for ( i = 0; i < ( DiskImageSize / sizeof ( UWORD)); i++)
  622.         {
  623.             InactiveDiskImage.ImageData[ i] = DiskImageData[ i];
  624.         }
  625.         if ( !( InactiveClipImage.ImageData = AllocMem( ClipImageSize, MEMF_CHIP)))
  626.         {
  627.             return 0;
  628.         }
  629.         ActiveClipImage.ImageData = &InactiveClipImage.ImageData[ Kick36 ? 52 : 0];
  630.         SelClipImage.ImageData = &InactiveClipImage.ImageData[ Kick36 ? 104 : 0];
  631.         for ( i = 0; i < ( ClipImageSize / sizeof ( UWORD)); i++)
  632.         {
  633.             InactiveClipImage.ImageData[ i] = ClipImageData[ i];
  634.         }
  635.     }
  636. #endif    /* SNAPGFX */
  637.  
  638.     return 1;
  639. }
  640.